<template>
	<view class="">
		<view class="nav_top-bg">
			<u-navbar title="免费图纸">
				<view class="u-nav-slot" slot="left">
					<u-icon name="arrow-left" @click="go_black" size="19"></u-icon>
					<u-line direction="column" :hairline="false" length="16" margin="0 10px"></u-line>
					<u-icon name="home" @click="goHome" size="20"></u-icon>
				</view>
			</u-navbar>
		</view>
		<!-- 顶部轮播图 -->
		<view class="">
			<view class="lunbo">
				<u-swiper :list="list1" imgMode="aspectFit" height="400rpx" radius="0" indicator indicatorMode="dot"
					keyName="image"></u-swiper>
				<view class="sheji">{{content_info.title}}</view>
				<image @click="shoucang_click"
					:src="content_info.shoucang == 1 ? '../static/shoucang_xz_icon.png' : '../static/shoucang_icon.png'"
					mode="widthFix" class="shoucang"></image>
			</view>
			<!-- 图纸 -->
			<view class="tuzhi-info">
				<view class="tuzhi-info-w">
					<view class="tz-tit">图纸详情</view>
					<view class="">
						<view class="tuzhi-num">图纸编号 &nbsp;&nbsp;{{content_info.info_no}}</view>
						<view class="tuzhi-num">土建造价 &nbsp;&nbsp;{{content_info.diyinfo.zaojia}} 万元</view>
						<view class="tuzhi-num">建筑面积 &nbsp;&nbsp;{{content_info.diyinfo.mianji}} m²</view>
						<view class="tuzhi-num">设计风格 &nbsp;&nbsp;{{content_info.diyinfo.fenggename}}</view>
						<view class="tuzhi-num">面 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;宽
							&nbsp;&nbsp;{{content_info.diyinfo.miankuan}} 米</view>
						<view class="tuzhi-num">进 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;深
							&nbsp;&nbsp;{{content_info.diyinfo.jinshen}} 米</view>
						<view class="tuzhi-num">建筑层数 &nbsp;&nbsp;{{content_info.diyinfo.ceng}}层</view>
					</view>
				</view>
			</view>
			<!-- 项目简介 -->
			<view class="tuzhi-info">
				<view class="tuzhi-info-w">
					<view class="tz-tit">项目简介</view>
					<view class="">
						<view class="tuzhi-num">{{content_info.diyinfo.xiangmu}}</view>
						<image class="xmtup" v-for="(project_img,index) in content_info.diyinfo.xiangmu_images_url"
							:key="index" :src="project_img" mode="widthFix"></image>

					</view>
				</view>
			</view>
			<!-- 项目简介 -->
			<!-- <view class="tuzhi-info">
				<view class="tuzhi-info-w">
					<view class="tz-tit">平面图</view>
					<view class="">
						<view class="tuzhi-num">{{content_info.diyinfo.pingmian == null ? '' : content_info.diyinfo.pingmian}}</view>
						<image class="xmtup" v-for="(pingmian_img,index) in content_info.diyinfo.pingmian_images_url"
							:key="index" :src="pingmian_img ? pingmian_img : ''" mode="widthFix"></image>

					</view>
				</view>
			</view> -->
			<!-- 效果图 -->
			<view class="tuzhi-info">
				<view class="tuzhi-info-w">
					<view class="tz-tit">案例展示</view>
					<view class="">
						<view class="tuzhi-num">
							{{content_info.diyinfo.xiaoguo == null ? '' : content_info.diyinfo.xiaoguo}}
						</view>
						<image class="xmtup" v-for="(xiaoguo_img,index) in content_info.diyinfo.xiaoguo_images_url"
							:key="index" :src="xiaoguo_img ? xiaoguo_img : ''" mode="widthFix"></image>

					</view>
				</view>
			</view>
			<!-- 公司简介 -->
			<view class="company">
				<view class="d-flex align-items w-630 justify-content-space-between">
					<view class="d-flex align-items">
						<image class="tx-gs" :src="content_info.user.avatar" mode=""></image>
						<view class="gs-t">
							{{content_info.userinfo.company_name ? content_info.userinfo.company_name : content_info.userinfo.company_contact}}
						</view>
					</view>
					<view class="go_see" @click="gosee">去看看</view>
				</view>
				<view class="w-630 jianjie">{{content_info.userinfo.instr ? content_info.userinfo.instr : ''}}</view>
			</view>
			<!-- 案例 -->
			<view class="anliList">
				<u-tabs :list="anli_list" lineWidth="48rpx" :current="current" lineColor="#FF6400" :activeStyle="{
            color: '#FF6400',
            fontWeight: 'bold',
            transform: 'scale(1.05)'
        }" @click="anli_click"></u-tabs>
			</view>
			<!-- 设计案例 -->
			<view class="fengge-list" v-if="anli_list[current].id == 6">
				<view class="w-690">
					<view class="choose-fengge margin-top-30" v-for="(info_list,index) in infoLists" :key="index"
						@click="sheji_anli_detial(info_list)">
						<view class="image_postion">
							<image :src="info_list.zhutu_images_firsturl" mode="widthFix" class="fenggeImg"></image>
						</view>
						<view class="fengge-t">{{info_list.content2.title}}</view>
						<view class="type-list d-flex align-items">
							<view class="type-list-m">{{info_list.mianji}}m²</view>
							<view class="type-list-m">{{info_list.price}}万</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 建房案例 -->
			<view class="fengge-list" v-if="anli_list[current].id == 7">
				<view class="w-690">
					<view class="choose-fengge margin-top-30" v-for="(info_list,index) in infoLists" :key="index"
						@click="jianfang_anli_detial(info_list)">
						<view class="image_postion">
							<image :src="info_list.anli_images_first" mode="widthFix" class="fenggeImg"></image>
						</view>
						<view class="fengge-t">{{info_list.content2.title}}</view>
						<view class="type-list d-flex align-items">
							<view class="type-list-m">{{info_list.mianji}}m²</view>
							<view class="type-list-m">长{{info_list.jinshen}}m</view>
							<view class="type-list-m">宽{{info_list.miankuan}}m</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 装修案例 -->
			<view class="fengge-list" v-if="anli_list[current].id == 8">
				<view class="w-690">
					<view class="choose-fengge margin-top-30" v-for="(info_list,index) in infoLists" :key="index">
						<view class="image_postion">
							<image :src="info_list.zhutu_images_first" @click="anli_detial(info_list)" mode="widthFix"
								class="fenggeImg"></image>
						</view>
						<view class="" @click="anli_detial(info_list)">
							<view class="fengge-t">{{info_list.content2.title}}</view>
							<view class="type-list d-flex align-items">
								<view class="type-list-m">{{info_list.mianji}}m²</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 图纸信息 -->
			<view class="fengge-list" v-if="anli_list[current].id == 9">
				<view class="w-690">
					<view class="choose-fengge margin-top-30" v-for="(info_list,index) in infoLists" :key="index"
						@click="tuzhi_go(info_list)">
						<view class="image_postion">
							<image :src="info_list.pingmian_images_first" mode="widthFix" class="fenggeImg"></image>
						</view>
						<view class="fengge-t">{{info_list.content2.title}}</view>
						<view class="type-list d-flex align-items">
							<view class="type-list-m">{{info_list.mianji}}m²</view>
							<view class="type-list-m">{{info_list.jiegouname}}</view>
							<view class="type-list-m">宽{{info_list.miankuan}}m</view>
							<view class="type-list-m">长{{info_list.jinshen}}m</view>
							<view class="type-list-m">{{info_list.wudingname}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 产品信息 -->
			<view class="fengge-list" v-if="anli_list[current].id == 11">
				<view class="w-690">
					<view class="shopping d-flex align-items justify-content-space-between">
						<view class="shopping_list" v-for="(info_list,index) in infoLists" :key="index">
							<view class="shopping_postion">
								<image class="shopping_phone" :src="info_list.product_images_first" mode="widthFix">
								</image>
							</view>
							<view class="">
								<view class="sp-name">{{info_list.product_name}}</view>
								<view class="sp-num"> <text class="fuhao">￥</text> {{info_list.price}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="foot_btn d-flex align-items justify-content-center">
			<view class="foot_btn-but">
				<u-button text="获取联系方式" @click="get_phone" color="#FF6400"></u-button>
			</view>
		</view>
		<!-- 获取电话弹窗 -->
		<view class="">
			<u-popup :show="show_pop" round="10" :safeAreaInsetBottom="false" mode="center" @close="close">
				<view class="get_phone">
					<view class="phone-t">联系方式</view>
					<view class="phone-num">{{content_info.userinfo.company_phone}}</view>
					<!-- <view class="shengyu">剩余免费次数：<text class="cishu">2次</text> </view> -->
					<view class="phone-w">
						<u-button text="确定" shape="circle" @click="queding" color="#FF6400"></u-button>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	import {
		getXinxiContent,
		setshouchang,
		getinfotype,
		deleteInfo,
		getXinxilist
	} from '@/api/user.js'
	export default {
		data() {
			return {
				list1: [],
				current: 0,
				anli_list: [],
				infoLists: [],
				show_pop: false,
				content_id: '',
				content_info: {},
				page: 1,
				limit: 7,
			}
		},
		async onLoad(option) {
			this.content_id = option.content_id
			await this.get_tuzhi_detail()
			await this.get_info_type()
			this.get_jianfang_list()
		},
		onReachBottom() {
			this.page++
			this.get_jianfang_list()
		},
		onPullDownRefresh() {
			this.page = 1
			this.get_jianfang_list()
		},
		methods: {
			// 获取图纸详情
			async get_tuzhi_detail() {
				var data = {
					id: this.content_id
				}
				await getXinxiContent(data).then(res => {
					console.log("获取图纸详情", res);
					if (res.code == 1) {
						this.content_info = res.data.content_info
						let m = []
						for (let s of this.content_info.diyinfo.zhutu_images_url) {
							console.log("选惠安的啥结果", s);
							m.push({
								image: s
							})
						}
						this.list1 = m
					}
				})
			},
			// 获取我发布的信息类型
			async get_info_type() {
				console.log("这个都快死了封疆大吏", this.content_info.group_id);
				var data = {
					group_id: this.content_info.group_id,
				}
				await getinfotype(data).then(res => {
					console.log("获取发布类型的信息类型", res);
					if (res.code == 1) {
						this.anli_list = res.data.infotypelist;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			// 获取我发布的信息列表
			get_jianfang_list() {
				console.log("88888888", this.anli_list);
				var data = {
					page: this.page,
					limit: this.limit,
					user_id: this.content_info.user_id,
					group_id: this.content_info.group_id,
					type: this.anli_list[this.current].id,
					own: 1
				}
				getXinxilist(data).then(res => {
					console.log("的发生大法师", res);
					if (res.code == 1) {
						if (this.page == 1) {
							this.infoLists = res.data.list
						} else {
							this.infoLists = this.infoLists.concat(res.data.list)
						}
						uni.stopPullDownRefresh()
					}
				})
			},
			// 修改发布的信息
			set_my_info(e) {
				uni.navigateTo({
					url: '/pagesB/info_fabu/guzhu_info_fabu?id=' + e.group_id + '&infotype_id=' + e.infotype_id +
						'&content_id=' + e.content_id + '&show_type_info=1'
				})
			},
			// 删除发布的消息
			del_my_info(e) {
				console.log("删除sssssss", e);
				let that = this
				var data = {
					id: e.content_id
				}
				deleteInfo(data).then(res => {
					console.log("删除发布的消息", res);
					if (res.code == 1) {
						uni.showModal({
							title: '删除信息',
							content: '确定要删除此信息吗？',
							success(s) {
								if (s.confirm) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									that.get_jianfang_list()
								}
								if (s.cancel) {
									console.log("用户点击了取消");
								}
							},
							fail(err) {
								console.log("失败了", err);
							}

						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			go_black() {
				uni.navigateBack({
					delta: 1
				})
			},
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			// 点机收藏按钮
			shoucang_click() {
				console.log("点击收藏按钮");
				var data = {
					content_id: this.content_info.id
				}
				console.log("数据库为", data);
				setshouchang(data).then(res => {
					console.log("收藏的店铺为", res);
					if (res.code == 1) {
						uni.showToast({
							title: '收藏成功',
							icon: 'success'
						})
						this.get_tuzhi_detail()
					} else {
						uni.showToast({
							title: '取消收藏',
							icon: 'none'
						})
						this.get_tuzhi_detail()
					}
				})
			},
			gosee() {
				uni.navigateTo({
					url: '/pagesA/anli_zhanshi/shejishi_detail?group_id=' + this.content_info.group_id +
						'&user_id=' + this.content_info.user_id
				})
			},
			// 设计案例详情
			sheji_anli_detial(e) {
				console.log("跳转到案例详情", e);
				uni.navigateTo({
					url: '/pagesA/anli_zhanshi/anli_detail?content_id=' + e.content_id
				})
			},
			// 建房案例详情
			jianfang_anli_detial(e) {
				console.log("跳转到案例详情", e);
				uni.navigateTo({
					url: '/pagesA/anli_zhanshi/anli_detail?content_id=' + e.content_id
				})
			},
			// 查看案例详情
			anli_detial(e) {
				console.log("跳转到案例详情", e);
				uni.navigateTo({
					url: '/pagesA/anli_zhanshi/anli_detail?content_id=' + e.content_id
				})
			},
			// 查看图纸详情
			tuzhi_go(e) {
				uni.navigateTo({
					url: '/pagesA/index_top/tuzhi_detail?content_id=' + e.content_id
				})
			},
			anli_click(item) {
				console.log('item', item);
				this.current = item.index
				this.page = 1
				this.get_jianfang_list()
			},
			get_phone() {
				if (!uni.getStorageSync('token')) {
					uni.showToast({
						title: '请登录后查看',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 500)
				} else {
					this.show_pop = true
				}
			},
			queding() {
				this.show_pop = false
			},
		}
	}
</script>

<style>
	.shopping_postion {
		width: 335rpx;
		position: relative;
	}

	.sp-num {
		font-size: 36rpx;
		font-weight: 600;
		color: #FF4D4F;
		margin: 0rpx 0 15rpx 24rpx;
	}

	.sp-name {
		width: 295rpx;
		font-size: 30rpx;
		color: #333;
		font-weight: 600;
		margin-left: 20rpx;
		margin-top: 20rpx;
		overflow: hidden;
		display: -webkit-box;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.shopping_phone {
		width: 335rpx;
		display: block;
		border-top-right-radius: 8rpx;
		border-top-left-radius: 8rpx;
	}

	.shopping_list {
		width: 335rpx;
		background-color: #fff;
		border-radius: 8rpx;
	}

	.shopping {
		width: 690rpx;
		margin: 20rpx auto;
		flex-wrap: wrap;
	}

	.hour_time {
		font-size: 26rpx;
		color: #999999;
	}

	.del-set {
		position: absolute;
		right: 20rpx;
		top: 30rpx;
	}

	.del_go-del,
	.set_info-set {
		font-size: 26rpx;
		color: #FF6400;
		margin-top: 20rpx;
		padding: 8rpx 20rpx;
		border-radius: 8rpx;
		background: rgba(0, 0, 0, 0.67);
	}

	.set_info-set {
		color: #FFF !important;
	}

	.set_info {
		font-size: 30rpx;
		color: #444;
		margin-left: 30rpx;
	}

	.del_go {
		font-size: 30rpx;
		color: #FF6400;
	}

	.gugong-info {
		width: 690rpx;
		background-color: #fff;
		border-radius: 10rpx;
		margin: 20rpx auto;
		padding: 25rpx 0;
	}

	.pinlun {
		width: 45rpx;
		display: block;
	}

	.plnum {
		font-size: 26rpx;
		color: #9E9E9E;
		margin-left: 7rpx;
	}

	.pinglun-magin {
		margin-right: 50rpx;
	}

	/* 获取电话弹窗 */
	.get_phone {
		width: 540rpx;
	}

	.phone-t {
		font-size: 34rpx;
		font-weight: 600;
		text-align: center;
		color: #1D2129;
		margin-bottom: 53rpx;
		padding-top: 40rpx;
	}

	.phone-num {
		font-size: 56rpx;
		font-weight: 600;
		text-align: center;
		color: #232323;
		margin-bottom: 30rpx;
	}

	.shengyu {
		font-size: 28rpx;
		font-weight: normal;
		color: #999999;
		text-align: center;
	}

	.cishu {
		font-size: 28rpx;
		font-weight: normal;
		color: #232323 !important;
	}

	.phone-w {
		width: 480rpx;
		margin: auto;
		margin-top: 29rpx;
		padding-bottom: 30rpx;
	}

	/* end */
	.foot_btn-but {
		width: 670rpx;
		margin: auto;
	}

	.foot_btn {
		width: 750rpx;
		height: 128rpx;
		position: fixed;
		bottom: 0;
		background-color: #fff;
		box-shadow: 0rpx 4rpx 23rpx 0rpx #999;
	}

	.type-list {
		margin-left: 20rpx;
		padding-bottom: 40rpx;
	}

	.type-list-m {
		padding: 7rpx 15rpx;
		font-size: 20rpx;
		color: #FF4D4F;
		border-radius: 4.5px;
		background: #FDF2F2;
		margin-right: 10rpx;
	}

	.fengge-t {
		font-size: 30rpx;
		font-weight: 700;
		line-height: 50rpx;
		color: #333333;
		margin: 27rpx 0 10rpx 20rpx;
	}

	.fenggeImg {
		width: 690rpx;
		display: block;
	}

	.image_postion {
		width: 690rpx;
		position: relative;
	}

	.choose-fengge {
		width: 690rpx;
		background-color: #fff;
		overflow: hidden;
		border-radius: 10rpx;
		margin-bottom: 25rpx;
	}

	.anliList {
		width: 690rpx;
		margin: auto;
		margin-top: 50rpx;
	}

	.jianjie {
		font-size: 28rpx;
		line-height: 46rpx;
		color: #999999;
	}

	.go_see {
		width: 110rpx;
		height: 48rpx;
		font-size: 24rpx;
		line-height: 50rpx;
		text-align: center;
		color: #FEFFFE;
		border-radius: 8rpx;
		background: #FF6400;
	}

	.gs-t {
		font-size: 32rpx;
		font-weight: normal;
		color: #1C2023;
	}

	.tx-gs {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		display: block;
		margin-right: 20rpx;
	}

	.xmtup {
		width: 600rpx;
		display: block;
		margin-top: 20rpx;
	}

	.tuzhi-num {
		font-size: 36rpx;
		font-weight: normal;
		line-height: 56rpx;
		color: #9E9E9E;
	}

	.tz-tit {
		font-size: 36rpx;
		font-weight: 600;
		text-align: center;
		color: #333333;
		padding-top: 50rpx;
		margin-bottom: 30rpx;
	}

	.tuzhi-info-w {
		width: 600rpx;
		margin: auto;
		padding-bottom: 30rpx;
	}

	.shoucang {
		width: 64rpx;
		display: block;
		position: absolute;
		top: 15rpx;
		right: 20rpx;
	}

	.company {
		width: 690rpx;
		margin: auto;
		margin-top: 30rpx;
		background: #fff;
		border-radius: 10rpx;
		padding: 30rpx 0;
	}

	.tuzhi-info {
		width: 690rpx;
		margin: auto;
		margin-top: 30rpx;
		background: #fff;
		border-radius: 10rpx;
	}

	.sheji {
		font-size: 30rpx;
		font-weight: 600;
		margin-top: 20rpx;
		color: #333333;
		margin-left: 30rpx;
	}

	.lunbo {
		width: 690rpx;
		height: 490rpx;
		background: #fff;
		border-radius: 10rpx;
		margin: auto;
		margin-top: 30rpx;
		overflow: hidden;
		position: relative;
	}

	page {
		background-color: #F7F8FB;
		padding-bottom: 120rpx;
	}
</style>